//
//  HMVisitorView.m
//  HMWeiBoOC
//
//  Created by GD on 16/9/20.
//  Copyright © 2016年 geduo. All rights reserved.
//

#import "HMVisitorView.h"

@interface HMVisitorView ()
@property (weak, nonatomic) IBOutlet UIImageView *turnBgView;

@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;

@property (weak, nonatomic) IBOutlet UILabel *messageLabel;

@end

@implementation HMVisitorView
- (IBAction)loginBtnClick:(UIButton *)sender {
    if (self.loginBlock) {
        self.loginBlock();
    }
}

- (IBAction)registerBtnClick:(id)sender {
    if (self.loginBlock) {
        self.loginBlock();
    }
}

+(instancetype)visitorView{
    return [[NSBundle mainBundle] loadNibNamed:@"HMVisitorView" owner:nil options:nil].lastObject;
}


-(void)updateVisitorInfo:(NSString *)message andImageName:(NSString *)imageName{

    if (message && imageName) {
        self.messageLabel.text = message;
        self.iconImageView.image = [UIImage imageNamed:imageName];
    }else{
        [self startAnimation];
    }

}

-(void)startAnimation{
    CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];

    anim.toValue = @(2 * M_PI);
    anim.duration = 20;
    anim.repeatCount = MAXFLOAT;
    
    anim.removedOnCompletion = NO;
    
    [self.turnBgView.layer addAnimation:anim forKey:nil];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    
}

@end
